//查询所有考试跳转到分段页面
<template>
  <div class="exam">
    <el-form :inline="true" :model="formInline" class="demo-form-inline" size="small">
      <el-form-item label="试题名称">
        <el-input v-model="formInline.source" placeholder="请输入试题名称"></el-input>
      </el-form-item>
      <el-form-item label="测评人">
        <el-input v-model="formInline.teacherName" placeholder="请输入测评人"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="getScore()" size="small">查询</el-button>
        <el-button type="warning" @click="resetGetScore()" size="small">重置</el-button>

      </el-form-item>
    </el-form>
    <el-table ref="filterTable" :data="score" v-loading="loading">
      <el-table-column
        prop="source"
        label="试题名称"
      >
      </el-table-column>
      <el-table-column
        prop="studentName"
        label="测试人">
      </el-table-column>
      <el-table-column prop="createDate" label="测试时间" width="200"></el-table-column>

      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope">
          <el-button @click="view(scope.row)" type="primary" size="small">查看详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-row type="flex" justify="center" align="middle" class="pagination">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pagination.current"
        :page-sizes="[10,20]"
        :page-size="pagination.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pagination.total">
      </el-pagination>
    </el-row>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        form : {} , //保存点击以后当前试卷的信息
        pagination : { //分页后的考试信息
          current : 1 , //当前页
          total : null , //记录条数
          size : 10 //每页条数
        } ,
        loading : false , //加载标识符
        dialogVisible : false ,
        formInline : {
          source : '' ,
          teacherName : ''
        }
      }
    } ,
    created () {
      this.getScore ()
      this.loading = true //数据加载则遮罩表格
    } ,
    methods : {
      resetGetScore () {
        this.formInline.source = ''
        this.formInline.teacherName = ''
        this.getScore ()
      } ,
      getScore () {
        this.$axios (
          {
            methods : 'get' ,
            url : '/api/findEvaluation' ,
            params : {
              page : this.pagination.current ,
              size : this.pagination.size ,
              source : this.formInline.source ,
              teacherName : this.formInline.teacherName
            }
          }
        ).then ( res => {
          if ( res.data.code == 200 ) {
            this.loading = false //数据加载完成去掉遮罩
            this.score = res.data.data.records
            this.pagination = { ... res.data.data }
          }
        } )
      } ,
      //改变当前记录条数
      handleSizeChange ( val ) {
        this.pagination.size = val
        this.getScore ()
      } ,
      //改变当前页码，重新发送请求
      handleCurrentChange ( val ) {
        this.pagination.current = val
        this.getScore ()
      } ,
      formatter ( row , column ) {
        return row.address;
      } ,
      filterTag ( value , row ) {
        return row.tag === value;
      } ,
      filterHandler ( value , row , column ) {
        const property = column[ "property" ];
        return row[ property ] === value;
      } ,
      view ( row ) {
        this.$router.push ( {
          path : '/evaluationRecord' , query : {
            source : row.source ,
            eid : row.id
          }
        } )
      }
    }
  };
</script>
<style lang="scss" scoped>
  .exam {
    padding: 0px 40px;

    .page {
      margin-top: 20px;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .edit {
      margin-left: 20px;
    }
  }
</style>
